<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/DeciderUWBIRED.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00467.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">DeciderUWBIRED.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * DeciderUWBIRED.h</span>
<a name="l00003"></a>00003 <span class="comment"> * Author: Jerome Rousselot &lt;jerome.rousselot@csem.ch&gt;</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright: (C) 2008-2010 Centre Suisse d&#39;Electronique et Microtechnique (CSEM) SA</span>
<a name="l00005"></a>00005 <span class="comment"> *              Wireless Embedded Systems</span>
<a name="l00006"></a>00006 <span class="comment"> *              Jaquet-Droz 1, CH-2002 Neuchatel, Switzerland.</span>
<a name="l00007"></a>00007 <span class="comment"> */</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="preprocessor">#ifndef _UWBIRENERGYDETECTIONDECIDERV2_H</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define _UWBIRENERGYDETECTIONDECIDERV2_H</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;MiXiMDefs.h&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;Signal_.h&quot;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;Mapping.h&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;BaseDecider.h&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;IEEE802154A.h&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;UWBIRPacket.h&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;MacToPhyInterface.h&quot;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">class </span><a class="code" href="a00175.html" title="Physical layer that models an Ultra Wideband Impulse Radio wireless communication system...">PhyLayerUWBIR</a>;
<a name="l00024"></a>00024 <span class="keyword">class </span>AirFrame;
<a name="l00025"></a>00025 
<a name="l00061"></a><a class="code" href="a00080.html">00061</a> <span class="keyword">class </span>MIXIM_API <a class="code" href="a00080.html" title="This class implements a model of an energy detection receiver that demodulates UWB-IR burst position ...">DeciderUWBIRED</a>: <span class="keyword">public</span> <a class="code" href="a00020.html" title="Provides some base functionality for most common deciders.">BaseDecider</a> {
<a name="l00062"></a>00062 <span class="keyword">private</span>:
<a name="l00063"></a>00063   <span class="keywordtype">bool</span> trace, stats;
<a name="l00064"></a>00064   <span class="keywordtype">long</span> nbFailedSyncs, nbSuccessfulSyncs;
<a name="l00065"></a>00065   <span class="keyword">mutable</span> <span class="keywordtype">double</span> nbSymbols, allThresholds;
<a name="l00066"></a>00066   <span class="keywordtype">double</span> vsignal2, pulseSnrs;
<a name="l00067"></a>00067 <span class="keyword">protected</span>:
<a name="l00068"></a>00068   <span class="keyword">typedef</span> std::map&lt;Signal*, int&gt; tSignalMap;
<a name="l00069"></a>00069   <span class="keywordtype">double</span> syncThreshold;
<a name="l00070"></a>00070   <span class="keywordtype">bool</span> syncAlwaysSucceeds;
<a name="l00071"></a>00071   <span class="keywordtype">bool</span> channelSensing;
<a name="l00072"></a>00072   <span class="keywordtype">bool</span> synced;
<a name="l00073"></a>00073   <span class="keywordtype">bool</span> alwaysFailOnDataInterference;
<a name="l00074"></a>00074   <a class="code" href="a00225.html" title="Class that keeps track of the number of packets sent.">UWBIRPacket</a> packet;
<a name="l00075"></a>00075   <span class="keyword">mutable</span> cOutVector receivedPulses;
<a name="l00076"></a>00076   cOutVector syncThresholds;
<a name="l00077"></a>00077   <a class="code" href="a00175.html" title="Physical layer that models an Ultra Wideband Impulse Radio wireless communication system...">PhyLayerUWBIR</a>* uwbiface;
<a name="l00078"></a>00078   <span class="keywordtype">int</span> nbCancelReceptions;
<a name="l00079"></a>00079   <span class="keyword">mutable</span> <span class="keywordtype">int</span> nbFinishTrackingFrames;
<a name="l00080"></a>00080 
<a name="l00081"></a>00081   <span class="keyword">typedef</span> <a class="code" href="a00049.html" title="Defines it values by concatenating one or more Mappings to a reference Mapping.">ConcatConstMapping&lt;std::multiplies&lt;double&gt;</a> &gt; <a class="code" href="a00049.html" title="Defines it values by concatenating one or more Mappings to a reference Mapping.">MultipliedMapping</a>;
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 <span class="keyword">public</span>:
<a name="l00085"></a><a class="code" href="a00080.html#a1ea6df6903891318b6d15881f1908984">00085</a>   <span class="keyword">const</span> <span class="keyword">static</span> <a class="code" href="a00201.html" title="Helper function to initialize signal change identifier on use and not on initializing static sections...">simsignalwrap_t</a> <a class="code" href="a00080.html#a1ea6df6903891318b6d15881f1908984" title="Signal for emitting UWBIR packets.">catUWBIRPacketSignal</a>;
<a name="l00086"></a>00086   <span class="keyword">const</span> <span class="keyword">static</span> <span class="keywordtype">double</span>          noiseVariance; <span class="comment">// P=-116.9 dBW // 404.34E-12;   v²=s²=4kb T R B (T=293 K)</span>
<a name="l00087"></a>00087   <span class="keyword">const</span> <span class="keyword">static</span> <span class="keywordtype">double</span>          peakPulsePower; <span class="comment">//1.3E-3 W peak power of pulse to reach  0dBm during burst; // peak instantaneous power of the transmitted pulse (A=0.6V) : 7E-3 W. But peak limit is 0 dBm</span>
<a name="l00088"></a>00088 
<a name="l00089"></a>00089   <a class="code" href="a00080.html" title="This class implements a model of an energy detection receiver that demodulates UWB-IR burst position ...">DeciderUWBIRED</a>( <a class="code" href="a00079.html" title="This class is the interface for a Decider to the BasePhyLayer.">DeciderToPhyInterface</a>* phy
<a name="l00090"></a>00090                 , <span class="keywordtype">double</span>                 sensitivity
<a name="l00091"></a>00091                 , <span class="keywordtype">int</span>                    myIndex
<a name="l00092"></a>00092                 , <span class="keywordtype">bool</span>                   debug );
<a name="l00093"></a>00093 
<a name="l00102"></a>00102   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="a00070.html#ae19a201633e5b2bf2d545921049b4f26" title="Initialize the decider from XML map data.">initFromMap</a>(<span class="keyword">const</span> <a class="code" href="a00070.html#a7f3ee545f2ae8b0d8d1814c98917f5b6" title="Used at initialisation to pass the parameters to the AnalogueModel and Decider.">ParameterMap</a>&amp; params);
<a name="l00103"></a>00103 
<a name="l00104"></a>00104   <span class="keywordtype">double</span> getAvgThreshold()<span class="keyword"> const </span>{
<a name="l00105"></a>00105     <span class="keywordflow">if</span> (nbSymbols &gt; 0)
<a name="l00106"></a>00106       <span class="keywordflow">return</span> allThresholds / nbSymbols;
<a name="l00107"></a>00107     <span class="keywordflow">else</span>
<a name="l00108"></a>00108       <span class="keywordflow">return</span> 0;
<a name="l00109"></a>00109   };
<a name="l00110"></a>00110 
<a name="l00111"></a>00111   <span class="keyword">static</span> <span class="keywordtype">double</span> getNoiseValue() {
<a name="l00112"></a>00112      <span class="keywordflow">return</span> normal(0, sqrt(noiseVariance));
<a name="l00113"></a>00113   }
<a name="l00114"></a>00114 
<a name="l00117"></a>00117   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00020.html#ae3c39418955737e6bae1a71a4b86d518" title="Cancels processing a AirFrame.">cancelProcessSignal</a>();
<a name="l00118"></a>00118 
<a name="l00119"></a>00119   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00020.html#a3d59c0be545b6d7db1233c2bb256eb5d" title="Method to be called by an OMNeT-module during its own finish(), to enable a decider to do some things...">finish</a>();
<a name="l00120"></a>00120 
<a name="l00123"></a><a class="code" href="a00080.html#aea537e08fe1735faa06ae4f26ee30d9c">00123</a>   <span class="keyword">enum</span> <a class="code" href="a00080.html#aea537e08fe1735faa06ae4f26ee30d9c" title="Control message kinds specific to DeciderUWBIRED. Currently defines a message kind that informs the M...">UWBIRED_CTRL_KIND</a> {
<a name="l00124"></a>00124       SYNC_SUCCESS=<a class="code" href="a00134.html#a36bc50a86bf1cc0f9efd374613d61a52a25b918f3c2f7bd926610b544bc78497a" title="Stores the id on which classes extending BasePhy should continue their own kinds.">MacToPhyInterface::LAST_BASE_PHY_KIND</a>+1,
<a name="l00125"></a>00125       SYNC_FAILURE,
<a name="l00126"></a>00126       <span class="comment">// add other control messages kinds here (from decider to mac, e.g. CCA)</span>
<a name="l00127"></a>00127   };
<a name="l00128"></a>00128 
<a name="l00129"></a>00129   <span class="comment">// compatibility function to allow running MAC layers that depend on channel state information</span>
<a name="l00130"></a>00130   <span class="comment">// from PHY layer. Returns last SNR</span>
<a name="l00131"></a>00131   <span class="keyword">virtual</span> <a class="code" href="a00044.html" title="Provides information about the current state of the channel:">ChannelState</a> <a class="code" href="a00020.html#a35e3f8f4e683747fbec1618ee1608982" title="A function that returns information about the channel state.">getChannelState</a>() <span class="keyword">const</span>;
<a name="l00132"></a>00132 
<a name="l00133"></a>00133 <span class="keyword">protected</span>:
<a name="l00140"></a><a class="code" href="a00080.html#a8f260e182096aa6e810512b06046af35">00140</a>   <span class="keyword">virtual</span> <a class="code" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaa" title="The current state of processing for a signal.">eSignalState</a> <a class="code" href="a00080.html#a8f260e182096aa6e810512b06046af35" title="Returns the next signal state (END, HEADER, NEW).">getNextSignalState</a>(<a class="code" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaa" title="The current state of processing for a signal.">eSignalState</a> CurState)<span class="keyword"> const </span>{
<a name="l00141"></a>00141     <span class="keywordflow">switch</span>(CurState) {
<a name="l00142"></a>00142       <span class="keywordflow">case</span> NEW:           <span class="keywordflow">return</span> <a class="code" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaaaf0a66719215a9be8335546666facaab6" title="Waiting for the header of the signal.">EXPECT_HEADER</a>;                             <span class="keywordflow">break</span>;
<a name="l00143"></a>00143       <span class="keywordflow">default</span>:            <span class="keywordflow">break</span>;
<a name="l00144"></a>00144     }
<a name="l00145"></a>00145     <span class="keywordflow">return</span> <a class="code" href="a00020.html#a4a8ddbaf158b593d4aabeac39c1d36ad" title="Returns the next signal state (END, HEADER, NEW).">BaseDecider::getNextSignalState</a>(CurState);
<a name="l00146"></a>00146   }
<a name="l00147"></a>00147 
<a name="l00154"></a>00154   <span class="keyword">virtual</span> simtime_t <a class="code" href="a00020.html#a5e45eb03d1a7f3653385181236714f21" title="Returns the next handle time for scheduler.">getNextSignalHandleTime</a>(<span class="keyword">const</span> airframe_ptr_t frame) <span class="keyword">const</span>;
<a name="l00155"></a>00155 
<a name="l00156"></a>00156   <span class="keyword">virtual</span> simtime_t <a class="code" href="a00020.html#ab53849078ba0481ea80a8926bdedd5f0" title="Processes the end of the header of a received Signal.">processSignalHeader</a>(airframe_ptr_t frame);
<a name="l00157"></a>00157 
<a name="l00165"></a>00165   <span class="keyword">virtual</span> <a class="code" href="a00075.html" title="A class to represent the result of a processed packet (that is not noise) by the Decider.">DeciderResult</a>* <a class="code" href="a00020.html#ac6ef3a4cf1b91bcec788b540d61bfeba" title="Creates the DeciderResult from frame.">createResult</a>(<span class="keyword">const</span> airframe_ptr_t frame) <span class="keyword">const</span>;
<a name="l00166"></a>00166 
<a name="l00167"></a>00167   std::pair&lt;bool, double&gt; decodePacket(<span class="keyword">const</span> airframe_ptr_t frame, std::vector&lt;bool&gt;* receivedBits, <span class="keyword">const</span> <a class="code" href="a00051.html" title="currently unused">IEEE802154A::config</a>&amp; cfg) <span class="keyword">const</span>;
<a name="l00168"></a>00168 
<a name="l00169"></a>00169   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> attemptSync(<span class="keyword">const</span> airframe_ptr_t frame);
<a name="l00170"></a>00170 
<a name="l00171"></a>00171   <span class="comment">// first value is energy from signal, other value is total window energy</span>
<a name="l00172"></a>00172   <span class="keyword">static</span>
<a name="l00173"></a>00173   std::pair&lt;double, double&gt; integrateWindow( <span class="keywordtype">int</span>                        symbol
<a name="l00174"></a>00174                                            , simtime_t_cref             now
<a name="l00175"></a>00175                                            , simtime_t_cref             burst
<a name="l00176"></a>00176                                            , <span class="keyword">const</span> AirFrameVector&amp;      airFrameVector
<a name="l00177"></a>00177                                            , <span class="keyword">const</span> <a class="code" href="a00058.html" title="Represents a not changeable mapping (mathematical function) from domain with at least the time to a A...">ConstMapping</a> *<span class="keyword">const</span>  signalPower
<a name="l00178"></a>00178                                            , <span class="keyword">const</span> airframe_ptr_t       frame
<a name="l00179"></a>00179                                            , <span class="keyword">const</span> <a class="code" href="a00051.html" title="currently unused">IEEE802154A::config</a>&amp; cfg);
<a name="l00180"></a>00180 
<a name="l00181"></a>00181 <span class="keyword">private</span>:
<a name="l00184"></a>00184   <a class="code" href="a00080.html" title="This class implements a model of an energy detection receiver that demodulates UWB-IR burst position ...">DeciderUWBIRED</a>(<span class="keyword">const</span> <a class="code" href="a00080.html" title="This class implements a model of an energy detection receiver that demodulates UWB-IR burst position ...">DeciderUWBIRED</a>&amp;);
<a name="l00187"></a>00187   <a class="code" href="a00080.html" title="This class implements a model of an energy detection receiver that demodulates UWB-IR burst position ...">DeciderUWBIRED</a>&amp; <a class="code" href="a00070.html#a301214aaf9e08d83fd4a060e72c10488" title="Assignment operator is not allowed.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00080.html" title="This class implements a model of an energy detection receiver that demodulates UWB-IR burst position ...">DeciderUWBIRED</a>&amp;);
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 };
<a name="l00190"></a>00190 
<a name="l00191"></a>00191 <span class="preprocessor">#endif  </span><span class="comment">/* _UWBIRENERGYDETECTIONDECIDERV2_H */</span>
<a name="l00192"></a>00192 
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>DeciderUWBIRED.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
